#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
#endregion Using

namespace PhotoGallery.Core.Business
{
    public class AccountRoleKey
    {
        #region Field and Properties

        private int roleId = 0;
        /// <summary>
        /// 
        /// </summary>
        public int RoleId
        {
            get { return roleId; }
            set
            {
                if (value != roleId)
                {
                    roleId = value;
                }
            }
        }

        private int accountId = 0;
        /// <summary>
        /// 
        /// </summary>
        public int AccountId
        {
            get { return accountId; }
            set
            {
                if (value != accountId)
                {
                    accountId = value;
                }
            }
        }


        #endregion

        #region Constructors

        public AccountRoleKey()
        {
        }

        public AccountRoleKey(int roleId, int accountId)
        {
            this.RoleId = roleId;
            this.AccountId = accountId;
        }

        #endregion

        #region Overrides

        public override int GetHashCode()
        {
            return this.RoleId.GetHashCode() + this.AccountId.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj == null) { return false; }
            if (this.GetType() != obj.GetType()) { return false; }

            return this.RoleId == ((AccountRoleKey)obj).RoleId && this.AccountId == ((AccountRoleKey)obj).AccountId;
        }

        public static bool operator ==(AccountRoleKey left, AccountRoleKey right)
        {
            if (Object.ReferenceEquals(left, right)) { return true; }
            if ((object)left == null || (object)right == null) { return false; }

            return left.RoleId == right.RoleId && left.AccountId == right.AccountId;
        }

        public static bool operator !=(AccountRoleKey left, AccountRoleKey right)
        {
            return !(left == right);
        }

        #endregion
    }

    public class AccountRole : Business.BusinessBase<AccountRole, AccountRoleKey>
    {
        #region Fields and Properties

        private DateTime addDate = DateTime.MinValue;
        /// <summary>
        /// 
        /// </summary>
        public DateTime AddDate
        {
            get { return addDate; }
            set
            {
                if (value != addDate)
                {
                    MarkChanged("AddDate");
                    addDate = value;
                }
            }
        }

        private int status = 0;
        /// <summary>
        /// 
        /// </summary>
        public int Status
        {
            get { return status; }
            set
            {
                if (value != status)
                {
                    MarkChanged("Status");
                    status = value;
                }
            }
        }




        #endregion Fields and Properties

        #region Constructors

        public AccountRole()
        {
        }

        #endregion Constructors

        #region Base overrides

        protected override void ValidationRules()
        {
        }

        protected override AccountRole DataSelect(AccountRoleKey id)
        {
            return Services.DALService.AccountRoleService.Select(id);
        }

        protected override void DataUpdate()
        {
            Services.DALService.AccountRoleService.Update(this);
        }

        protected override void DataInsert()
        {
            Services.DALService.AccountRoleService.Insert(this);
        }

        protected override void DataDelete()
        {
            Services.DALService.AccountRoleService.Delete(this);
        }

        #endregion Base overrides



        internal static ICollection<Role> Find(Account account)
        {
            return Services.DALService.AccountRoleService.Find(account);
        }
    }


}
